package com.tbit.api;

import cn.hutool.core.bean.BeanUtil;
import com.tbit.manager.api.WorkbenchApi;
import com.tbit.manager.api.dto.ItemsDTO;
import com.tbit.uqbike.object.pojo.dto.MachineDataDTO;
import com.tbit.uqbike.object.pojo.dto.TodoItemsDTO;
import com.tbit.uqbike.object.pojo.vo.MachineDataVO;
import com.tbit.uqbike.service.business.WorkbenchService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.*;

/**
 * 工作台实现类 openfeign接口
 * @author <a href="mailto:liu.haoxiang@tbit.com.cn">BUGXiang</a>
 * @version 1.0
 * @since 2024-11-26
 */
@RestController
public class WorkbenchApiImpl implements WorkbenchApi {

    @Resource
    private WorkbenchService workbenchService;


    /**
     * 待办项
     * @param dto dto
     * @return map
     */
    @Override
    public Map<String, Object> todoItems(ItemsDTO dto) {
        TodoItemsDTO todoItemsDTO = new TodoItemsDTO();
        BeanUtils.copyProperties(dto, todoItemsDTO);
        return workbenchService.todoItems(todoItemsDTO).getData();
    }

    /**
     * 车辆数据
     * @param itemsDTO itemsDTO
     * @return map
     */
    @Override
    public Map<String, Object> machineData(ItemsDTO itemsDTO) {
        MachineDataDTO dto = new MachineDataDTO();
        dto.setAccountIds(new ArrayList<>(Collections.singletonList(itemsDTO.getAccountId())));
        dto.setRegionId(itemsDTO.getRegionId());
        MachineDataVO data = workbenchService.machineData(dto).getData();
        return BeanUtil.beanToMap(data);
    }
}
